17extern const char mrb_digitmap[];
19#define RSTRING_EMBED_LEN_MAX \
20 ((mrb_int)(sizeof(void*) * 3 + sizeof(void*) - 32 / CHAR_BIT - 1))
38 char ary[RSTRING_EMBED_LEN_MAX+1];
41#define RSTR_SET_TYPE(s, type) ((s)->flags = ((s)->flags & ~(MRB_STR_TYPE_MASK|MRB_STR_EMBED_LEN_MASK)) | MRB_STR_##type)
43#define MRB_STR_NORMAL 0
44#define MRB_STR_SHARED 1
45#define MRB_STR_FSHARED 2
46#define MRB_STR_NOFREE 4
47#define MRB_STR_EMBED 8
48#define MRB_STR_TYPE_MASK 15
50#define MRB_STR_EMBED_LEN_SHIFT 6
51#define MRB_STR_EMBED_LEN_BITS 5
52#define MRB_STR_EMBED_LEN_MASK (((1 << MRB_STR_EMBED_LEN_BITS) - 1) << MRB_STR_EMBED_LEN_SHIFT)
54#define MRB_STR_BINARY 16
55#define MRB_STR_SINGLE_BYTE 32
56#define MRB_STR_STATE_MASK 48
58#define RSTR_EMBED_P(s) ((s)->flags & MRB_STR_EMBED)
59#define RSTR_SET_EMBED_FLAG(s) ((s)->flags |= MRB_STR_EMBED)
60#define RSTR_SET_EMBED_LEN(s, n) do {\
62 (s)->flags &= ~MRB_STR_EMBED_LEN_MASK;\
63 (s)->flags |= (tmp_n) << MRB_STR_EMBED_LEN_SHIFT;\
65#define RSTR_SET_LEN(s, n) do {\
66 if (RSTR_EMBED_P(s)) {\
67 RSTR_SET_EMBED_LEN((s),(n));\
70 (s)->as.heap.len = (mrb_ssize)(n);\
73#define RSTR_EMBED_PTR(s) (((struct RStringEmbed*)(s))->ary)
74#define RSTR_EMBED_LEN(s)\
75 (mrb_int)(((s)->flags & MRB_STR_EMBED_LEN_MASK) >> MRB_STR_EMBED_LEN_SHIFT)
76#define RSTR_EMBEDDABLE_P(len) ((len) <= RSTRING_EMBED_LEN_MAX)
78#define RSTR_PTR(s) ((RSTR_EMBED_P(s)) ? RSTR_EMBED_PTR(s) : (s)->as.heap.ptr)
79#define RSTR_LEN(s) ((RSTR_EMBED_P(s)) ? RSTR_EMBED_LEN(s) : (s)->as.heap.len)
80#define RSTR_CAPA(s) (RSTR_EMBED_P(s) ? RSTRING_EMBED_LEN_MAX : (s)->as.heap.aux.capa)
82#define RSTR_SHARED_P(s) ((s)->flags & MRB_STR_SHARED)
83#define RSTR_FSHARED_P(s) ((s)->flags & MRB_STR_FSHARED)
84#define RSTR_NOFREE_P(s) ((s)->flags & MRB_STR_NOFREE)
87# define RSTR_SINGLE_BYTE_P(s) ((s)->flags & MRB_STR_SINGLE_BYTE)
88# define RSTR_SET_SINGLE_BYTE_FLAG(s) ((s)->flags |= MRB_STR_SINGLE_BYTE)
89# define RSTR_UNSET_SINGLE_BYTE_FLAG(s) ((s)->flags &= ~MRB_STR_SINGLE_BYTE)
90# define RSTR_WRITE_SINGLE_BYTE_FLAG(s, v) (RSTR_UNSET_SINGLE_BYTE_FLAG(s), (s)->flags |= v)
91# define RSTR_COPY_SINGLE_BYTE_FLAG(dst, src) RSTR_WRITE_SINGLE_BYTE_FLAG(dst, RSTR_SINGLE_BYTE_P(src))
93# define RSTR_SINGLE_BYTE_P(s) TRUE
94# define RSTR_SET_SINGLE_BYTE_FLAG(s) (void)0
95# define RSTR_UNSET_SINGLE_BYTE_FLAG(s) (void)0
96# define RSTR_WRITE_SINGLE_BYTE_FLAG(s, v) (void)0
97# define RSTR_COPY_SINGLE_BYTE_FLAG(dst, src) (void)0
99#define RSTR_SET_ASCII_FLAG(s) RSTR_SET_SINGLE_BYTE_FLAG(s)
100#define RSTR_BINARY_P(s) ((s)->flags & MRB_STR_BINARY)
105#define mrb_str_ptr(s) ((struct RString*)(mrb_ptr(s)))
106#define RSTRING(s) mrb_str_ptr(s)
107#define RSTRING_PTR(s) RSTR_PTR(RSTRING(s))
108#define RSTRING_EMBED_LEN(s) RSTR_EMBED_LEN(RSTRING(s))
109#define RSTRING_LEN(s) RSTR_LEN(RSTRING(s))
110#define RSTRING_CAPA(s) RSTR_CAPA(RSTRING(s))
111#define RSTRING_END(s) (RSTRING_PTR(s) + RSTRING_LEN(s))
112#define RSTRING_CSTR(mrb,s) mrb_string_cstr(mrb, s)
122#define mrb_str_index_lit(mrb, str, lit, off) mrb_str_index(mrb, str, lit, mrb_strlen_lit(lit), off);
322#define mrb_str_buf_new(mrb, capa) mrb_str_new_capa(mrb, (capa))
329#define mrb_string_value_ptr(mrb, str) RSTRING_PTR(str)
331#define mrb_string_value_len(mrb, str) RSTRING_LEN(str)
333#define mrb_str_strlen(mrb, s) strlen(RSTR_PTR(s))
366#define mrb_str_to_inum(mrb, str, base, badcheck) mrb_str_to_integer(mrb, str, base, badcheck)
402#define mrb_str_cat_lit(mrb, str, lit) mrb_str_cat(mrb, str, lit, mrb_strlen_lit(lit))
432#define mrb_str_cat2(mrb, str, ptr) mrb_str_cat_cstr(mrb, str, ptr)
433#define mrb_str_buf_cat(mrb, str, ptr, len) mrb_str_cat(mrb, str, ptr, len)
434#define mrb_str_buf_append(mrb, str, str2) mrb_str_cat_str(mrb, str, str2)
mruby common platform definition"
#define MRB_END_DECL
End declarations in C mode.
Definition common.h:28
#define MRB_BEGIN_DECL
Start declarations in C mode.
Definition common.h:26
#define MRB_API
Declare a public mruby API function.
Definition common.h:108
mrb_value mrb_str_cat(mrb_state *mrb, mrb_value str, const char *ptr, size_t len)
Returns a concatenated string comprised of a Ruby string and a C string.
Definition string.c:3129
mrb_value mrb_str_append(mrb_state *mrb, mrb_value str, mrb_value str2)
Adds str2 to the end of str1.
Definition string.c:3207
mrb_int mrb_str_index(mrb_state *mrb, mrb_value str, const char *p, mrb_int len, mrb_int offset)
Finds the index of a substring in a string.
Definition string.c:854
mrb_value mrb_str_plus(mrb_state *mrb, mrb_value a, mrb_value b)
Adds two strings together.
Definition string.c:1120
mrb_value mrb_str_resize(mrb_state *mrb, mrb_value str, mrb_int len)
Resizes the string's length.
Definition string.c:1052
mrb_bool mrb_str_equal(mrb_state *mrb, mrb_value str1, mrb_value str2)
Returns true if the strings match and false if the strings don't match.
Definition string.c:1318
mrb_value mrb_str_cat_cstr(mrb_state *mrb, mrb_value str, const char *ptr)
Returns a concatenated string comprised of a Ruby string and a C string.
Definition string.c:3172
mrb_value mrb_obj_as_string(mrb_state *mrb, mrb_value obj)
Returns an object as a Ruby string.
Definition string.c:2257
mrb_value mrb_str_substr(mrb_state *mrb, mrb_value str, mrb_int beg, mrb_int len)
Returns a sub string.
Definition string.c:2010
mrb_value mrb_str_intern(mrb_state *mrb, mrb_value self)
Returns a symbol from a passed in Ruby string.
Definition string.c:2239
char * mrb_str_to_cstr(mrb_state *mrb, mrb_value str)
Returns a newly allocated C string from a Ruby string.
Definition string.c:1085
mrb_value mrb_str_dup(mrb_state *mrb, mrb_value str)
Duplicates a string object.
Definition string.c:1353
mrb_value mrb_ptr_to_str(mrb_state *mrb, void *p)
Converts pointer into a Ruby string.
Definition string.c:2283
void mrb_str_concat(mrb_state *mrb, mrb_value self, mrb_value other)
Appends self to other.
Definition string.c:1105
mrb_value mrb_str_dup_frozen(mrb_state *mrb, mrb_value str)
Returns a frozen string object.
Definition string.c:1362
int mrb_str_cmp(mrb_state *mrb, mrb_value str1, mrb_value str2)
Returns 0 if both Ruby strings are equal.
Definition string.c:1241
Definition boxing_nan.h:40